package o;

import android.app.Activity;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import o.ah.g;
import o.dky.d;
import o.dky.h;
import o.dky.i;
import o.dky.j;

public class cip implements cja {
    protected Boolean ʻ = Boolean.valueOf(false);
    private boolean ʼ = false;
    private boolean ʽ = true;
    protected View ˊ;
    private ProgressBar ˊॱ;
    protected TextView ˋ;
    private boolean ˋॱ = false;
    protected ImageView ˎ;
    protected ImageView ˏ;
    private OnClickListener ˏॱ;
    private boolean ͺ = false;
    protected View ॱ;
    private View ॱˊ;
    private String ॱॱ;
    private boolean ᐝ = false;

    public cip(boolean z) {
        this.ʻ = Boolean.valueOf(z);
    }

    public View ˏ(LayoutInflater layoutInflater) {
        View inflate = layoutInflater.inflate(i.ˎˎ, null);
        azb.ˏ(inflate);
        ˎ(inflate);
        inflate.setVisibility(8);
        return inflate;
    }

    public void ˎ(final View view) {
        this.ॱ = view;
        this.ˊॱ = (ProgressBar) view.findViewById(h.ﹳ);
        this.ˋ = (TextView) view.findViewById(h.ॱˌ);
        this.ˊ = view.findViewById(h.ॱـ);
        this.ˎ = (ImageView) view.findViewById(h.ʻˋ);
        this.ˏ = (ImageView) view.findViewById(h.ᐨ);
        this.ॱˊ = view.findViewById(h.ﾟ);
        evf.ॱ(this.ॱˊ, d.ˏॱ);
        this.ˊ.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ cip ॱ;

            public void onClick(View view) {
                if (this.ॱ.ˏॱ != null) {
                    this.ॱ.ˊ(view);
                    this.ॱ.ˏॱ.onClick(this.ॱ.ˊ);
                }
            }
        });
        View findViewById = view.findViewById(h.ʾॱ);
        if (findViewById != null) {
            findViewById.setOnClickListener(new OnClickListener(this) {
                final /* synthetic */ cip ॱ;

                public void onClick(View view) {
                    if (this.ॱ.ˏॱ != null) {
                        this.ॱ.ˊ(view);
                        this.ॱ.ˏॱ.onClick(this.ॱ.ˊ);
                    }
                }
            });
        }
        if (this.ᐝ) {
            ˋ(this.ॱॱ, this.ͺ, this.ʽ);
        } else {
            ˊ(view);
        }
    }

    public void ˏ() {
        ॱ(0);
    }

    public void ˋ(OnClickListener onClickListener) {
        this.ˏॱ = onClickListener;
    }

    public void ॱ(String str, boolean z) {
        this.ᐝ = true;
        this.ʽ = true;
        this.ॱॱ = str;
        this.ͺ = z;
        ˋ(str, z, this.ʽ);
    }

    public void ˋ(String str, boolean z, boolean z2) {
        if (this.ॱ == null) {
            Logger.e("DefaultLoadingController", "stopLoading, loadingPager == null");
            return;
        }
        this.ᐝ = true;
        this.ॱॱ = str;
        this.ͺ = z;
        this.ʽ = z2;
        View findViewById = this.ॱ.findViewById(h.ـॱ);
        if (z2) {
            findViewById.setVisibility(0);
            findViewById.setOnClickListener(new OnClickListener(this) {
                final /* synthetic */ cip ˏ;

                {
                    this.ˏ = r1;
                }

                public void onClick(View view) {
                    eth.ˊ(this.ˏ.ॱ.getContext());
                }
            });
            ˋ(false);
        } else if (this.ʼ) {
            findViewById.setVisibility(8);
            ˋ(true);
        } else {
            this.ॱ.findViewById(h.ߴ).setVisibility(8);
        }
        this.ˊॱ.setVisibility(8);
        if (this.ॱˊ != null) {
            this.ॱˊ.setVisibility(8);
        }
        this.ˊ.setVisibility(0);
        this.ˋ.setText(str);
        if (z) {
            this.ˊ.setClickable(true);
        }
    }

    private void ˋ(boolean z) {
        View findViewById = this.ॱ.findViewById(h.ˉ);
        if (!((etj) cdb.ॱ(etj.class)).ॱ()) {
            findViewById.setVisibility(8);
        }
        LayoutParams layoutParams = (LayoutParams) findViewById.getLayoutParams();
        if (z) {
            layoutParams.weight = 0.0f;
        } else {
            layoutParams.weight = 1.0f;
        }
        findViewById.setOnClickListener(new OnClickListener(this) {
            final /* synthetic */ cip ˎ;

            {
                this.ˎ = r1;
            }

            public void onClick(View view) {
                eth.ॱ(this.ˎ.ॱ.getContext());
            }
        });
    }

    public boolean ˎ() {
        return this.ॱ != null && this.ॱ.getVisibility() == 0;
    }

    public void ˏ(int i, boolean z) {
        if (i == ResponseBean.SERVICE_ZONE_NOT_SUPPORT_ERROR && eut.ˏ().ˋ()) {
            ॱ(8);
            eut.ˏ().ˊ((Activity) this.ॱˊ.getContext());
            return;
        }
        if (i == 3) {
            this.ॱॱ = ContentManager.getInstant().getContext().getResources().getString(j.ॱͺ);
            this.ʽ = true;
        } else if (i == ResponseBean.SERVER_UPGRADES_ERROR) {
            ʻ();
            this.ʽ = false;
        } else if (i == ResponseBean.SERVER_DELAY_RETRY) {
            this.ॱॱ = ContentManager.getInstant().getContext().getResources().getString(j.ʼˊ);
            ˋ();
            this.ʽ = false;
        } else {
            this.ॱॱ = ContentManager.getInstant().getContext().getResources().getString(j.ॱॱ);
            this.ʽ = false;
            this.ʼ = true;
        }
        ˋ(this.ॱॱ, z, this.ʽ);
    }

    public void ˋ() {
        this.ˎ.setVisibility(8);
        this.ˏ.setVisibility(0);
    }

    private void ʻ() {
        int i = -1;
        String ˏ = AsyLoader.ˏ();
        if (Logger.ˎ()) {
            Logger.ˏ("DefaultLoadingController", "maintainTime : " + ˏ);
        }
        if (ˏ != null) {
            try {
                i = Integer.parseInt(ˏ);
            } catch (NumberFormatException e) {
                if (Logger.ˎ()) {
                    Logger.ˏ("DefaultLoadingController", "NumberFormatException: " + e.getMessage());
                }
            }
        }
        Resources resources = ContentManager.getInstant().getContext().getResources();
        String str = "";
        if (i <= 0) {
            this.ॱॱ = resources.getString(j.ʻˊ);
        } else if (i < g.ॱˍ) {
            r0 = resources.getQuantityString(dky.g.ॱ, i, new Object[]{Integer.valueOf(i)});
            this.ॱॱ = resources.getString(j.ʼˋ, new Object[]{r0});
        } else if (i % 60 == 0) {
            r0 = resources.getQuantityString(dky.g.ˎ, i / 60, new Object[]{Integer.valueOf(i / 60)});
            this.ॱॱ = resources.getString(j.ʼˋ, new Object[]{r0});
        } else {
            int floor = (int) Math.floor(((double) i) / 60.0d);
            str = resources.getQuantityString(dky.g.ˎ, floor, new Object[]{Integer.valueOf(floor)});
            r0 = resources.getQuantityString(dky.g.ॱ, i % 60, new Object[]{Integer.valueOf(i % 60)});
            this.ॱॱ = resources.getString(j.ʽˊ, new Object[]{str, r0});
        }
    }

    protected void ˊ(View view) {
        this.ˊ.setClickable(false);
        this.ˊॱ.setVisibility(0);
        this.ˊ.setVisibility(8);
        if (this.ॱˊ != null) {
            this.ॱˊ.setVisibility(0);
        }
    }

    public void ˊ() {
        if (this.ॱ != null) {
            ˊ(this.ॱ);
        }
    }

    public void ॱ(int i) {
        if (this.ॱ != null) {
            this.ॱ.setVisibility(i);
        }
    }

    public void onEvent(int i) {
        if (i != 0) {
            ˏ(i, true);
            ॱ(0);
        } else if (this.ॱ == null || this.ॱ.getVisibility() != 8) {
            ॱ(8);
        }
    }

    public View ॱ() {
        return this.ॱ;
    }

    public void ˊ(boolean z) {
        this.ˋॱ = z;
    }
}
